<?php
include_once('include/init.php');
//登陆检测
function check_administrator_login(){
	global $db;
        $adminName = fs_get_value('AdminName');
	$adminPass = fs_get_value('AdminPass');
	$onlyKey = fs_get_value('onlyKey');
	if(strlen($adminName)==0||strlen($adminPass)==0){
	    fs_showmsg("账号或者密码不能为空,请重新输入!");
	}
	if($onlyKey!==SUPER_KEY_BACKOFFICE){
	    fs_showmsg("密钥输入错误,你无法进入系统!");
	}
        $sql = "select * from nettteach_member where passport='".$adminName."'  and type ='0' and state='1' ";
	$rows = $db -> row_query($sql);
	if(!$rows)  fs_showmsg('你输入的账号或密码不正确');
	$result = $db->query($sql);
	while($row = $db->fetch_array($result)){
	    if(md5($adminPass)!=$row['password'])
			 fs_showmsg('你输入的密码不正确');
	}
         $_SESSION['admin']=$adminName;
         fs_showmsg('登陆成功');
}
$action=fs_get_value('do');
if ($action=='login'){check_administrator_login();}

if ($_SESSION['admin']=='')
{
	fooee_display_loginform();
}
else
{   
	fooee_display_adminform();
}

?>
<?php
function fooee_display_loginform()
{
?>
	<html>
<head>
<title>网络教学综合平台管理登陆</title>
<style type="text/css">
<!--
body { font-size: 12px;  line-height: 130%;  color: #000; background: #fff; }
td { font-size: 12px; }
input { color: 333333; }
.input { color: #333333; height: 20px; padding-top: 2px; padding-left: 3px; border: 1px #999999 solid; background-image: url("images/inputbg.gif");}
.button {border: 2px outset; height: 25px; color: 333333; }
-->
</style>
</head>

<body>
<br><br><br><br>
<table border="0" cellspacing="1" cellpadding="1" align="center" bgcolor="#CCCCCC" width="500">
  <tr bgcolor="#FFFFFF"> 
    <td>
      <table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td><img src="images/1.jpg" width="500" height="129"></td>
        </tr>
      </table>
      <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" background="images/3.jpg" height="153">
        <tr>
          <td width="10"></td>
          <td width="158" background="images/2.jpg">&nbsp;</td>
          <td align="center"> 
            <table width="260" border="0" cellspacing="3" cellpadding="2">
              <form name="LoginForm" method="post" action="?do=login">
     <input type="hidden" name="action" value="login"/>
                
				<tr height=30></tr>
				<tr> 
                  <td align="right" width="100">用户名：</td>
                  <td><font color="#FFFFFF"> 
                    <input type="text" name="AdminName" size="18" class="input" style="width:108px" value="admin" />
                    </font></td>
                </tr>
  <tr> 
                  <td align="right" width="100">密　码：</td>
                  <td><font color="#FFFFFF"> 
                    <input type="password" name="AdminPass" size="18" class="input" style="width:108px" />
                    </font></td>
                </tr>






            <!--<tr> 
                  <td align="right" width="100">数据库：</td>
                  <td><font color="#FFFFFF"> 
<select name="school">
				   <?php $path=DIR_ROOT_P.'/'.DIR_CONFIG.'/school/';
				        $dir = str_replace("\\", "/", $path);
						if (is_dir($dir))
						{  
							if ($dh = opendir($dir)){
								while (($file = readdir($dh)) !== false){
									$filename=strpos($file,'.php');
									print_r($filename);
									 if ($file != "." && $file != ".." && $filename!='') {
									echo '<option value="'.$file.'">'.$file.'</option>';
									 }
								}
								closedir($dh);
							}
						}

?>
			</select>	  

                    </font></td>
                </tr>-->
				
				
    

                <tr> 
                  <td align="right" width="100">密　钥：</td>
                  <td><font color="#FFFFFF">                   
							<input type="text" name="onlyKey" size="18" class="input" style="width:108px" />
                          </font>
                      </font></td>
                </tr>

                <tr> 
                  <td width="100">&nbsp;</td>
                  <td height="28" valign="bottom"> 
                    <input name="sm1" value="　登　录　" class="button" type="submit" style="width:108px" />
					<div style="padding:2px;height:10px;color:#f00;font-weight:bold"></div>
					<div style="padding:2px;font-family:verdana;font-size:10px;text-align:right"></div>
                  </td>
                </tr>
              </form>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>


</body></html>


<?php
} 

function fooee_display_adminform()
{
?>
<html>
<head>

<title>新E代网络教学综合平台后台管理</title>
</head>
	<frameset rows="31,*" framespacing="0" border="0" frameborder="0">
		<frame src="adminhead.php" scrolling="no" name="Head" noresize>
		<frameset id="ContentSet" rows="80,*">
			<frame src="adminmenu.php" name="Menu">
			<frame src="fooee.php" name="MainContent" scrolling="yes" noresize>
		</frameset>
	</frameset>
<?php
}
?>